package board.pieces;

import java.awt.Color;

import board.grid.Grid;
import board.grid.Space;
/** A simple piece used for examples.  
 *  This piece is used in the test main
 *  method, but could server as a base for
 *  other pieces, if so desired.  This class
 *  has only the logic to put itself on the
 *  grid, be moved, be removed, and have its
 *  color changed.  
 * 
 * @author R.Wisniewski1101
 */
public class BasicPiece implements Piece {
	/** The current color */
	private Grid<? super Piece> grid;
	/** The current space on the grid */
	private Space space;
	/** The current color */
	private Color currentColor;
	/** Create a black piece */
	public BasicPiece() {setColor(Color.BLACK);}
	/** Create a piece with a given color */
	public BasicPiece(Color color) {setColor(color);}
	@Override
	public Space getCurrentSpace() {return space;}
	@Override
	public Grid<? super Piece> getGrid() {return grid;}
	@Override
	public void putSetfOnGrid(Grid<? super Piece> grid, Space space) {
		grid.put(space, this);
		this.grid = grid;
	}
	@Override
	public void removeSelfFromGrid() {
		grid.remove(space);
		grid = null;
		space = null;
	}
	@Override
	public void moveTo(Space space) {
		this.space = space;
		grid.remove(space);
		grid.put(space, this);
	}
	@Override
	public void setColor(Color color) {currentColor = color;}
	@Override
	public Color getColor() {return currentColor;}
}
